<template>
  <div class="wrapper">
    <swiper :options="swiperOption" v-if="showSwiper">
      <swiper-slide v-for="(item, index) in swiperList" :key="index">
        <img class="swiper-image" :src="item.imgUrl" />
      </swiper-slide>
      <div class="swiper-pagination" slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
export default {
  name: 'HomeSwiper',
  props: ['swiperList'],
  data() {
    return {
      swiperOption: {
        // 轮播图的蓝点，默认为蓝色
        pagination: '.swiper-pagination',
        loop: true,
        // 自动播放
        autoplay: 2000,
        autoplayDisableOnInteraction: false
      }
    }
  },
  computed: {
    showSwiper() {
      return this.swiperList.length
    }
  }
}
</script>

<style scoped lang="stylus">
// 样式穿透
.wrapper >>> .swiper-pagination-bullet-active {
  background-color: #fff;
}

.wrapper {
  overflow: hidden;
  width: 100%;
  // height: 31.25vw;
  height: 0;
  padding-bottom: 26.5%;
  background-color: #eee;

  .swiper-image {
    width: 100%;
    height: 100%;
  }
}
</style>
